package com.ushine.design.design.b_structural_type.e_facade.b_example;

public class EncryptFacade {
    //维持对子系统的引用
    private FileReader reader;
    private FileWriter writer;
    private CipherMachine machine;

    public EncryptFacade() {
        reader = new FileReader();
        writer = new FileWriter();
        machine = new CipherMachine();
    }

    /**
     * 业务方法
     * 读取文件
     * 加密文件
     * 写入文件
     *
     * @param fileNameSrc 源文件
     * @param fileNameDes 目标文件
     */
    public void fileEncrypt(String fileNameSrc, String fileNameDes) {
        String plainText = reader.read(fileNameSrc);
        String encrypt = machine.encrypt(plainText);
        writer.write(fileNameDes, encrypt);
    }
}
